{fx_template 'common/header'}
{if $_GPC['op']=='data_record' || $_GPC['op']=='record' || $_GPC['op']=='account'  ||  $_GPC['op']=='merchantAccount'}
<ul class="nav nav-tabs">
{if !MERCHANTID}
	<li {if $_GPC['op']=='data_record' || $_GPC['op']=='merchantAccount'}class="active"{/if}><a href="{php echo web_url('application/merchant/data_record', array('id'=>$id));}">金额变更</a></li>
	<li {if $_GPC['op']=='record'}class="active"{/if}><a href="{php echo web_url('application/merchant/record', array('id'=>$id));}">结算记录</a></li>
	<li {if $_GPC['op']=='account'}class="active"{/if}><a href="{php echo web_url('application/merchant/account', array('id'=>$id));}">去结算</a></li>
{else}
	<li {if $_GPC['op']=='data_record' || $_GPC['op']=='merchantAccount'}class="active"{/if}><a href="{php echo web_url('application/merchant/data_record');}">金额变更</a></li>
	<li {if $_GPC['op']=='record'}class="active"{/if}><a href="{php echo web_url('application/merchant/record');}">结算记录</a></li>
	<li {if $_GPC['op']=='account'}class="active"{/if}><a href="{php echo web_url('application/merchant/account');}">申请提现</a></li>
{/if}
</ul>
{/if}

{if $_GPC['op']=='account'}
<div class="main">
	<div class="panel panel-default">
		<div class="table-responsive">
			<table class="table table-hover" style="min-width: 300px;">
				<tbody>
					<tr>
						<td><image src="{php echo tomedia($merchant['logo']);}" style="max-width: 48px; max-height: 48px; border: 1px dotted gray"></td>
						<td>{$merchant['name']}</td>
						<td>总成交额：{if $merchant['amount']}{$merchant['amount']}元{else}0.00元{/if}</td>
						<td>可结算金额：{if $merchant['no_money']}{$merchant['no_money']}元{else}0.00元{/if}</td>
                        <td>线下付款：{if $merchant['delivery']}{$merchant['delivery']}元{else}0.00元{/if}</td>
						<td>上缴佣金：{php echo currency_format($merchant['no_money']*$merchant['percent']*0.01);}元</td>
						<td>佣金比：{if !empty($merchant['percent'])}{$merchant['percent']}%{else}0.00%{/if}</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
	{if !MERCHANTID}<ul class="nav nav-tabs">
	<li {if $_GPC['op']=='account' && $_GPC['accountType']=='weixin'}class="active"{/if}><a href="{php echo web_url('application/merchant/account', array('id'=>$id,'accountType'=>'weixin'));}">结算到微信钱包</a></li>
	<li {if $_GPC['op']=='account' && $_GPC['accountType']=='f2f' }class="active"{/if}><a href="{php echo web_url('application/merchant/account', array('id'=>$id,'accountType'=>'f2f'));}">面对面结算</a></li>
</ul>{/if}
{if $_GPC['op']=='account' && $_GPC['accountType']=='weixin'}
	<div id="weixin">
	    <div class="panel panel-default">
	    <div class="panel-heading">{php echo MERCHANTID?'提现':'结算'}注意</div>
	    <div class="panel-body">
            <div class="form-group">
            	<label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                1.<font color="red" size="3">总交易</font>金额：用户支付过的金额总和。<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;<1>以下情况会<font color="red" size="3">增加</font>总交易金额：<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;①.用户成功支付金额、后台转支付状态；<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;<2>以下情况会<font color="red" size="3">减少</font>总交易金额：<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;①.退款后、取消支付；<br>
                
                </label>
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                2.<font color="red" size="3">可结算</font>金额：可以结算给商户的实际金额。<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;<1>以下情况会将订单实际支付金额<font color="red" size="3">增加</font>到可结算金额【线下付款、后台转支付状态除外】：<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;①.核销后：后台报名设置核销，微信端扫码核销，微信端验证码核销；<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;<2>以下情况会<font color="red" size="3">减少</font>可结算金额：<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;①.用户结算后；<br>
                	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;②.已核销用户退款；
                </label>
                {if !MERCHANTID}
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                3.结算金额必须大于1元。
                </label>
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                4.请确认微信商户后台有足够的<font color="red" size="3">可用余额</font>。
                </label>
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                5.结算金额直接提现到该主办方<font color="red" size="3">提现微信号</font>的<font color="red" size="3">微信钱包</font>中，<font color="red" size="3">注意绑定正确的微信号</font>，必要时可结算1元到该微信号上<font color="red" size="3">验证</font>是否绑定正确。
                </label>
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                6.佣金举例：佣金百分比为10%，需要给主办方结算100元，则主办方实际到账90元，佣金为10元。
                </label>
			         <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">       接口调用规则：<br>
				
				◆ 给同一个实名用户付款，单笔单日限额2W/2W<br>
				
				◆ 给同一个非实名用户付款，单笔单日限额2000/2000<br>
				
				◆ 一个商户同一日付款总额限额100W<br>
				
				◆ 单笔最小金额默认为1元<br>
				
				◆ 每个用户每天最多可付款10次，可以在商户平台--API安全进行设置<br>
				
				◆ 给同一个用户付款时间间隔不得低于15秒
 			</label>
				{/if}
	   		</div>
	    </div>
	</div> 
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
<div class="panel panel-default">
    <div class="panel-heading">
        {php echo MERCHANTID?'提现':'结算'}
    </div>
    <div class="panel-body">
         <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">总交易金额</label>
            <div class="col-sm-9 col-xs-12">
                <div class="form-control-static">{if $account['amount']}{$account['amount']}元{else}0.00元{/if}</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">目前可结算金额</label>
            <div class="col-sm-9 col-xs-12">
                <div class="form-control-static">{if $merchant['no_money']}{$merchant['no_money']}元{else}0.00元{/if}【其中{if $merchant['no_money_doing']}{$merchant['no_money_doing']}元{else}0.00元{/if}为正在申请中的金额】</div>
            </div>
        </div>
        <div class="form-group" style="display:none">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">佣金百分比</label>
            <div class="col-sm-9 col-xs-12">
                <div class="form-control-static">{if $merchant['percent']}{$merchant['percent']}%{else}0.00%{/if}【到账金额 = 输入结算金额 - 输入结算金额 * 佣金百分比 ；】</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">输入结算金额</label>
            <div class="col-sm-8 col-lg-3 col-xs-12">
                <input class="form-control" name="money" id="" type="text" value="{$_GPC['money']}" placeholder="">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
            <div class="col-sm-9 col-xs-12">
                    <input type="hidden" name="id" value="{$id}">
                    <input type="hidden" name="accountType" value="{$_GPC['accountType']}">
                    <input type="hidden" name="token" value="{$_W['token']}">
                    <input name="submit" type="submit" value="{if MERCHANTID}申请{else}结 算{/if}" class="btn btn-primary span2" onclick="return confirm('确认？');return false;">
            </div>
           </div>
  
        </div>
    </div>
 
</form>
</div>
{/if}
{if $_GPC['op']=='account' && $_GPC['accountType']=='f2f'}

<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
<div class="panel panel-default">
    <div class="panel-heading">
        面对面结算
    </div>
    <div class="panel-body">
         <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">总交易金额</label>
            <div class="col-sm-9 col-xs-12">
                <div class="form-control-static">{if $account['amount']}{$account['amount']}元{else}0.00元{/if}</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">目前可结算金额</label>
            <div class="col-sm-9 col-xs-12">
                <div class="form-control-static">{if $account['no_money']}{$account['no_money']}元{else}0.00元{/if}【其中{if $account['no_money_doing']}{$account['no_money_doing']}元{else}0.00元{/if}为正在申请中的金额】</div>
            </div>
        </div>
        <div class="form-group" style="display:none">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">佣金百分比</label>
            <div class="col-sm-9 col-xs-12">
                <div class="form-control-static">{if $merchant['percent']}{$merchant['percent']}%{else}0.00%{/if}【到账金额 = 输入结算金额 - 输入结算金额 * 佣金百分比 ；】</div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">输入结算金额</label>
            <div class="col-sm-8 col-lg-3 col-xs-12">
                <input class="form-control" name="money" id="" type="text" value="{$_GPC['money']}" placeholder="">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
            <div class="col-sm-9 col-xs-12">
                    <input type="hidden" name="id" value="{$id}">
                    <input type="hidden" name="accountType" value="{$_GPC['accountType']}">
                    <input type="hidden" name="token" value="{$_W['token']}">
                    <input name="submit" type="submit" value="{if MERCHANTID}申请{else}结 算{/if}" class="btn btn-primary span2" onclick="return confirm('确认？');return false;">
            </div>
           </div>
  
        </div>
    </div>
 
</form>
{/if}
</div>
{elseif $_GPC['op']=='record'}
<div class="main">
   <div class="panel panel-default">
		<div class="table-responsive">
			<table class="table table-hover" style="min-width: 300px;">
				<tbody>
					<tr>
						<td><image src="{php echo tomedia($merchant['logo']);}" style="max-width: 48px; max-height: 48px; border: 1px dotted gray"></td>
						<td>{$merchant['name']}</td>
						<td>总成交额：{if $merchant['amount']}{$merchant['amount']}元{else}0.00元{/if}</td>
						<td>可结算金额：{if $merchant['no_money']}{$merchant['no_money']}元{else}0.00元{/if}</td>
                        <td>线下付款：{if $merchant['delivery']}{$merchant['delivery']}元{else}0.00元{/if}</td>
						<td>上缴佣金：{php echo currency_format($merchant['no_money']*$merchant['percent']*0.01);}元</td>
						<td>佣金比：{if !empty($merchant['percent'])}{$merchant['percent']}%{else}0.00%{/if}</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>

	<div class="panel panel-default">
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
					<tr>
						<th style="width:80px;">处理状态</th>
						<th style="width:80px;">结算金额</th>
						<th style="width:80px;">到账金额</th>
						<th style="width:80px;">佣金</th>
						<th style="width:80px;">佣金百分比</th>
						<th style="width:80px;">操作时间</th>
					</tr>
				</thead>
				<tbody>
					{loop $list $item}
					<tr>
						<td>
							{if $item['status']==1}<label class="label label-default label-default">待确认</label>{/if}
							{if $item['status']==2}<label class="label label-default label-danger">已确认，待打款</label>{/if}
							{if $item['status']==3}<label class="label label-default label-success">已打款</label>{/if}
						</td>
						<td>{$item['money']}元</td>
						<td>{$item['get_money']}元</td>
						<td>{if $item['commission']}{$item['commission']}{else}0.00{/if}</td>
						<td>{if $item['percent']}{$item['percent']}{else}0.00{/if}%</td>
						<td>{php echo date("Y-m-d H:i:s",$item['createtime'])}</td>
					</tr>
					{/loop}
				</tbody>
			</table>
		</div>
	</div>
	{$pager}
</div>

{elseif $_GPC['op']=='data_record'}
<div class="main">
    <div class="panel panel-default">
		<div class="table-responsive">
			<table class="table table-hover" style="min-width: 300px;">
				<tbody>
					<tr>
						<td><image src="{php echo tomedia($merchant['logo']);}" style="max-width: 48px; max-height: 48px; border: 1px dotted gray"></td>
						<td>{$merchant['name']}</td>
						<td>总成交额：{if $merchant['amount']}{$merchant['amount']}元{else}0.00元{/if}</td>
						<td>可结算金额：{if $merchant['no_money']}{$merchant['no_money']}元{else}0.00元{/if}</td>
                        <td>线下付款：{if $merchant['delivery']}{$merchant['delivery']}元{else}0.00元{/if}</td>
						<td>上缴佣金：{php echo currency_format($merchant['no_money']*$merchant['percent']*0.01);}元</td>
						<td>佣金比：{if !empty($merchant['percent'])}{$merchant['percent']}%{else}0.00%{/if}</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>

	<div class="panel panel-default">
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
					<tr>
						<th class="col-sm-2">操作</th>
						<th class="col-sm-4">金额变更</th>
						<th class="col-sm-4">详情</th>
						<th class="col-sm-2">变更时间</th>
					</tr>
				</thead>
				<tbody>
					{loop $moneyRecord $item2}
					<tr>
						<td>{if !empty($item2['records'])}订单ID：{$item2['recordsid']}<br>{$item2['records']['title']}{else}主办方结算{/if}</td>
						<td>{if $item2['type']==0}取消支付，总金额{elseif $item2['type']==1}支付成功，总金额{elseif $item2['type']==2}核销成功，可结算金额{elseif $item2['type']==3}取消核销，可结算金额{elseif $item2['type']==4}主办方结算，可结算金额{elseif $item2['type']==5}退款，收入{elseif $item2['type']==6}线下支付，核销成功{elseif $item2['type']==7}结算手续费{/if}&nbsp;&nbsp;  <span style="color:{if $item2['money']>0}#4cae4c{else}#F26C4F{/if};font-size: 20px;"><b>{if $item2['money']>0}+{/if}</b>{$item2['money']}</span></td>
						<td>{$item2['detail']}</td>
						<td>{php echo date("Y-m-d H:i:s",$item2['createtime'])}</td>
					</tr>
					{/loop}
				</tbody>
			</table>
		</div>
	</div>
	{$pager}
</div>

{elseif $_GPC['op']=='data'}
	 <div class="panel panel-default">
	    <div class="panel-heading">结算注意事项</div>
	    <div class="panel-body">
            <div class="form-group">
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                ◆ 给同一个实名用户付款，单笔单日限额2W/2W
                </label>
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                ◆ 一个商户同一日付款总额限额100W
                </label>
                 <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                ◆ 单笔最小金额默认为1元
                </label>
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
                ◆ 每个用户每天最多可付款10次，可以在商户平台--API安全进行设置
                </label>
                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-12 control-label" style="text-align: left;padding-right: 30px;">
               ◆ 给同一个用户付款时间间隔不得低于15秒
                </label>
            	
	   		</div>
	    </div>
	</div> 
<script type="text/javascript">
$(".oscrollLoading").scrollLoading();
require(['daterangepicker'], function($){
	$('.daterange').on('apply.daterangepicker', function(ev, picker) {
		$('#form1')[0].submit();
	});
});

	$(function(){
		$('.order-list').delegate('.js-jiesuan', 'click', function(e){
			e.stopPropagation();
			var $this = $(this);
			var id = $this.attr('order-id');
			var merchantid = "{$merchant['id']}";
			util.nailConfirm(this, function(state) {
				if(!state) return;
				$.post("{php echo web_url('application/merchant/jiesuan')}", { id : id,merchantid : merchantid }, function(data){
					util.tips(data.message);
				}, 'json');
			}, {html: '确认结算?'});
		});
		$('.order-list').delegate('.js-jiesuan-checked','click',function(e){
			e.stopPropagation();
			var order_ids = [];
			var $checks=$('.checkbox:checkbox:checked');
			$checks.each(function() {
				if (this.checked) {
					order_ids.push(this.value);
				};
			});
				var $this = $(this);
				var merchantid = "{$merchant['id']}";
				util.nailConfirm(this, function(state) {
				if(!state) return;
					util.message('系统准备结算选择订单,请不要离开页面', "{php echo web_url('application/merchant/jiesuan')}&merchantid="+merchantid+"&order_ids="+order_ids, 'success');
				}, {html: '确认结算选择订单?'});
			});
	});

</script>
{/if}
{fx_template 'common/footer'}